package no.uib.kwikktaim.gui.actionlisteners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import no.uib.kwikktaim.gui.MainWindow;

public class VolumeChanger implements ChangeListener, ActionListener {
	MainWindow mw;

	public VolumeChanger(MainWindow mw) {
		this.mw = mw;
	}

	@Override
	public void stateChanged(ChangeEvent e) {
		mw.getPlayer().changeVolume(mw.getSliderVolume().getValue());
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(mw.getPlayer().isMuted()) {
			mw.getButtonMute().setIcon(mw.getIconFullVolume());
		}
		else {
			mw.getButtonMute().setIcon(mw.getIconMute());
		}
		mw.getPlayer().mute();

	}

}
